<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    1050. Construct Binary Search Tree from Preorder Traversal
   </h1>
   <p>
    Return the root node of a binary
    <strong>
     search
    </strong>
    tree that matches the given
    <code>
     preorder
    </code>
    traversal.
   </p>
   <p>
    <em>
     (Recall that a binary search tree&nbsp;is a binary tree where for every
     <font face="monospace">
      node
     </font>
     , any descendant of
     <code>
      node.left
     </code>
     has a value
     <code>
      &lt;
     </code>
     &nbsp;
     <code>
      node.val
     </code>
     , and any descendant of
     <code>
      node.right
     </code>
     has a value
     <code>
      &gt;
     </code>
     &nbsp;
     <code>
      node.val
     </code>
     .&nbsp; Also recall that a preorder traversal&nbsp;displays the value of the&nbsp;
     <code>
      node
     </code>
     first, then traverses
     <code>
      node.left
     </code>
     , then traverses
     <code>
      node.right
     </code>
     .)
    </em>
   </p>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     Example 1:
    </strong>
   </p>
   <pre>
<strong>Input: </strong><span id="example-input-1-1">[8,5,1,7,10,12]</span>
<strong>Output: </strong><span id="example-output-1">[8,5,10,1,7,null,12]
<img alt="" src="https://assets.leetcode.com/uploads/2019/03/06/1266.png" style="height: 200px; width: 306px;"></span>
</pre>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     Note:
    </strong>
    &nbsp;
   </p>
   <ol>
    <li>
     <code>
      1 &lt;= preorder.length &lt;= 100
     </code>
    </li>
    <li>
     The values of
     <code>
      preorder
     </code>
     are distinct.
    </li>
   </ol>
  </div>
  <div>
   <h1 class="question_title">
    1050. 先序遍历构造二叉树
   </h1>
   <p>
    返回与给定先序遍历&nbsp;
    <code>
     preorder
    </code>
    相匹配的二叉搜索树（binary
    <strong>
     search
    </strong>
    tree）的根结点。
   </p>
   <p>
    <em>
     (回想一下，二叉搜索树是二叉树的一种，其每个节点都满足以下规则，对于&nbsp;
     <code>
      node.left
     </code>
     &nbsp;的任何后代，值总
     <code>
      &lt;
     </code>
     <code>
      node.val
     </code>
     ，而
     <code>
      node.right
     </code>
     的任何后代，值总
     <code>
      &gt;
     </code>
     <code>
      node.val
     </code>
     。此外，先序遍历首先显示节点的值，然后遍历
     <code>
      node.left
     </code>
     ，接着遍历
     <code>
      node.right
     </code>
     。）
    </em>
   </p>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     示例：
    </strong>
   </p>
   <pre><strong>输入：</strong>[8,5,1,7,10,12]
<strong>输出：</strong>[8,5,10,1,7,null,12]
<img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2019/03/08/1266.png" style="height: 200px; width: 306px;">
</pre>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     提示：
    </strong>
   </p>
   <ol>
    <li>
     <code>
      1 &lt;= preorder.length &lt;= 100
     </code>
    </li>
    <li>
     先序&nbsp;
     <code>
      preorder
     </code>
     &nbsp;中的值是不同的。
    </li>
   </ol>
  </div>
 </body>
</html>